﻿var _iv_CT047 = "";
var _iv_CT048 = "";
var _iv_C0047 = "";
var _iv_C0056 = "";
var _iv_CT051 = "";
var _iv_C0069 = "";
var _iv_CT041 = "";
var _iv_C0064 = "";
var _iv_CT049 = "";
var _iv_CT050 = "";
var _iv_C1002 = "";
var _iv_C1006 = "";
var _iv_C0022 = "";

var __FNickName = "";
var __MyNickName = "";
var __FEmail = "";
var __IsFriend = false;
var __IsLink = false;
var __IsAgreeFriend = false;
var __EmailOption = false;

var __gFMNO = "";
var __pageIsReLoad = true;
var __disabledObjId = "";

//添加新朋?朋友号，调用本函数对应的ID（如需要刷新页面不用传?
function $AddFriends$(sFriendMemberNo,disabledObjId) 
{
    if(disabledObjId){ __pageIsReLoad = false;__disabledObjId = disabledObjId;}
    __gFMNO = sFriendMemberNo; 
    showProgressBar(false,true);
    WebServices.User.Public.MemberRelation(sFriendMemberNo,$onsuccMemberRelation$);
}
function __AddFriends()
{
    $AddFriends$(__gFMNO,__disabledObjId);
}
//初始数据
function $onsuccMemberRelation$(result)
{
    showProgressBar(false,true);  
    if(result[0]=="NL")
    {
        $Login$(__AddFriends);return;//转向登录页，要么用通用组件在本地登?
    }
    else if(result[0]=="F")
    {
        //显示操作失败消息
    }
    else
    {
        $("$divIput$").style.display = "none";
        if(result[0]=="myFull")
        {            
            _iv_C0064 = result[1][0];
            _iv_C0022 = result[1][1];
            var _iv_CT067 = result[1][2];
            var sIsFrindText = "<div><h3>"+_iv_CT067+"</h3><br /><p style='text-align: center;'><input type='button' value='"+_iv_C0064;
            sIsFrindText +="' class='buttong' onclick='__Empty()' /></p></div>";
            $ShowSampleBox$(sIsFrindText);
        }
        else if(result[0]=="fFull")
        {
            _iv_C0064 = result[1][0];
            _iv_C0022 = result[1][1];
            var _iv_CT068 = result[1][2];
            var sIsFrindText = "<div><h3>"+_iv_CT068+"</h3><br /><p style='text-align: center;'><input type='button' value='"+_iv_C0064;
            sIsFrindText +="' class='buttong' onclick='__Empty()' /></p></div>";
            $ShowSampleBox$(sIsFrindText);
        }
        else
        {
            __IsFriend = result[1];
            __IsLink = result[2];
            __IsAgreeFriend = result[3];
            __EmailOption = result[4];
            __FNickName = result[5];
            __MyNickName = result[6];
            __FEmail = result[7];
            _iv_CT047 = result[8][0];
            _iv_CT048 = result[8][1];
            _iv_C0047 = result[8][2];
            _iv_C0056 = result[8][3];
            _iv_CT051 = result[8][4];
            _iv_C0069 = result[8][5];
            _iv_CT041 = result[8][6];
            _iv_C0064 = result[8][7];
            _iv_CT049 = result[8][8];
            _iv_CT050 = result[8][9];
            _iv_C1002 = result[8][10];
            _iv_C1006 = result[8][11];
            _iv_C0022 = result[8][12];            
            if(__IsFriend)
            {
                var sIsFrindText = "<div><h3>"+_iv_CT041+"</h3><br /><p style='text-align: center;'><input type='button' value='"+_iv_C0064;
                sIsFrindText +="' class='buttong' onclick='__Empty()' /></p></div>";
                $ShowSampleBox$(sIsFrindText);            
            }
            else if(__IsLink)
            {
                var sIsLinkText = "<div><h3>"+_iv_CT049+"</h3><br /><p style='text-align: center;'><input type='button' value='"+_iv_C0064+"' class='buttong' onclick='__Empty()' /></p></div>";
                $ShowSampleBox$(sIsLinkText);
            }
            else if(!__IsAgreeFriend)
            {
                var sNoAgreeFText = "<div><h3>"+_iv_CT050+"</h3><br /><p style='text-align: center;'><input type='button' value='"+_iv_C0064+"' class='buttong' onclick='__Empty()' /></p></div>";
                $ShowSampleBox$(sNoAgreeFText);
            }
            else
            {
                if(__EmailOption)
                {
                    var sIsEmailText = "<div><h3>"+_iv_CT047+"</h3><p><strong>"+_iv_CT048+"</strong><br /><textarea id='$txtContent$' rows='6' style='width:95%;'></textarea>";
                    sIsEmailText += "</p><p style='text-align: center;'><input type='button' value='"+_iv_C0047+"' class='button' id='__Invit_OK' /> ";
                    sIsEmailText += "<input type='button' value='"+_iv_C0056+"' class='buttong' onclick='__Empty()' /></p></div>";
                    $ShowAddFrindWithMessage$(sIsEmailText);
                    $("$txtContent$").focus();
                }
                else
                {
                    var sNoEmailText = "<div><h3>"+_iv_CT051+"</h3><br /><p style='text-align: center;'><input type='button' value='"+_iv_C0069+"' class='button' id='__Invit_OK'/> ";
                    sNoEmailText += "<input type='button' value='"+_iv_C0056+"' onclick='__Empty()' class='buttong' /></p></div>";
                    $ShowAddFrind$(sNoEmailText);
                }
            }
        }
    }
}
function $ShowSampleBox$(text)
{
    var obj={a:""}
    $ShowMessageBox$(_iv_C0022,text,obj,__Empty);
}
function __Empty()
{
    $EndMessageBox$();
}

function $ShowAddFrindWithMessage$(text)
{
    var obj={f:__gFMNO,ef:true,fn:__FNickName,mn:__MyNickName,fe:__FEmail,tx:1}
    $ShowMessageBox$(_iv_C0022,text);
    $AddHandler$("click",$("__Invit_OK"),__ShowAddFrind,obj);
}

function $ShowAddFrind$(text)
{
    var obj={f:__gFMNO,ef:false,fn:"",mn:"",fe:"",tx:0}
    $ShowMessageBox$(_iv_C0022,text);
    $AddHandler$("click",$("__Invit_OK"),__ShowAddFrind,obj);
}

function __ShowAddFrind()
{
    var textC = "";
    if(this.tx==1)textC=$("$txtContent$").value;    
    WebServices.User.Public.AddNewFriend(this.f,this.ef,this.fn,this.mn,this.fe,textC,$onsuccAddNewFriend$,__onError);
}
function __onError()
{
    $EndMessageBox$();    
}

function $onsuccAddNewFriend$(result)
{
    if(result.State)
    {
        $("$Message$").innerHTML = "<div><h3>"+_iv_C1002+"</h3><p style='text-align: center;'><input type='button' value='"+_iv_C0064+"' class='buttong' onclick='javascript:$InviteOK$();' /></p></div>";
    }
    else
    {
        $("$Message$").innerHTML = "<div><h3>"+_iv_C1006+"</h3><p style='text-align: center;'><input type='button' value='"+_iv_C0064+"' class='buttong' onclick='javascript:__Empty();' /></p></div>";      
    }
}
function $InviteOK$()
{
    $EndMessageBox$();
    if(__pageIsReLoad)
    {
        window.location.reload();
    }
    else
    {
        if(__disabledObjId!="")
        {
            if($(__disabledObjId))
            {
                $(__disabledObjId).onclick = null;
                try{
                $(__disabledObjId).setAttribute("class","gray");
                }catch(e){
			    $(__disabledObjId).setAttribute("className","gray"); }
            }
        }
    }    
}